package com.heima.common.tess4j;

import lombok.Data;
import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * 封装了Tess4J配置类
 */
@Configuration
@Data
@ConfigurationProperties(prefix = "tess4j")
public class Tess4jClient {
    private String datapath;
    private String language;

    @Bean
    public ITesseract createTesseract(){
        //创建Tesseract对象
        ITesseract tesseract = new Tesseract();
        //设置识别语言环境（默认不支持中文，需要添加中文语言包）
        tesseract.setDatapath(datapath);//设置语言包的目录
        tesseract.setLanguage(language);//设置语言包的名称
        return tesseract;
    }

}
